type objType = Record<string, any>

export function tileTreeData(
  data: objType[],
  key: string = 'children',
  n = 0,
  res: objType[] = []
) {
  for (const i of data) {
    res.push({
      ...i
    })
    if (i[key]) {
      tileTreeData(i[key], key, n + 1, res)
    }
  }
  return res
}
